package utils;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Class to read properties file to set mapping metric type - event type and default access database.
 * 
 * @author Andy Cullache, Salvador Cortés
 */
public class ReadProperties {
	
	public static String errorTypes = null;
	public static String classificationTypes = null;
	public  static String URI = "";
	public  static String user = "";
	public static String password = "";	
	

	/**
	 * Reads the file containing the mapping properties of metric.
	 * 
	 * @param dir      Properties file path.
	 */
	public static void readMetricsTypes(String dir){
	    
		try {
	        Properties prop = new Properties();
	        prop.load(new FileInputStream(dir));
	        errorTypes = prop.getProperty("Error");
	        classificationTypes = prop.getProperty("Classification");
       } catch (IOException ex) {
            Logger.getLogger(ReadProperties.class.getName()).log(Level.SEVERE, null, ex);
        }
    } 

	
	/**
	 * Read the file containing the access data to the database.
	 * 
	 * @param dir      Properties file path.
	 * @throws IOException 
	 * @throws FileNotFoundException 
	 */
	public static void readDBAccesData(String dir) throws FileNotFoundException, IOException{
	    
	        Properties prop = new Properties();
	        prop.load(new FileInputStream(dir));
	        URI = prop.getProperty("URI");
	        user = prop.getProperty("user");
	        password = prop.getProperty("password");
    } 	
	
	
}
